﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;

namespace TextSplit
{

    enum UserType
    {
        Bank,
        User,

    }

    class Program
    {
        static string parten = @"^.{0,10}[第0-9零一二三四五六七八九十百千万章]{3,}.{1,20}$";

        static void Main(string[] args)
        {
           

            var file = @"F:\ccfy.txt";

            Split(file);
        }

        static void Split(string file)
        {
            string txt = string.Empty;
            using (var sm = new StreamReader(file, Encoding.Default))
            {
                txt = sm.ReadToEnd();
            }

            S(txt);
        }

        public class TextItem
        {
            public string Title { get; set; }
            public string Body { get; set; }

            public override string ToString()
            {
                return string.Format("[{0}],[{1}]", Title, Body);
            }
        }

        static void S(string sm)
        {
            var reg = new Regex(parten, RegexOptions.Multiline);

            var match = reg.Match(sm);

            var data = new List<TextItem>();

            while (match.Success)
            {
                var old = match;
                match = match.NextMatch();

                var title = sm.Substring(old.Index, old.Length - 1);
                var body = string.Empty;

                var start = old.Index + old.Length + 1;
                if (match.Success)
                {
                    body = sm.Substring(start, match.Index - start);
                }
                else
                {
                    body = sm.Substring(start);
                }

                if (!string.IsNullOrWhiteSpace(body))
                {
                    data.Add(new TextItem { Title = title, Body = body });
                }
            }

            var len = data.Count;
        }
    }
}
